package common

type Result struct {
	Success bool   `json:"success"`
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

func (r *Result) Ok(data any) *Result {
	r.Success = true
	r.Code = SuccessCode
	r.Message = "请求成功"
	r.Data = data
	return r
}

func Fail() *Result {
	return &Result{
		Success: false,
		Code:    FailCode,
		Message: "请求失败",
		Data:    nil,
	}
}
